package org.mikeliu.review.exp3;

import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.TreeMap;

class Student
{
	private int no;
	private String name;
	private int score;
	public Student(int no, String name, int score) 
	{
		this.no = no;
		this.name = name;
		this.score = score;
	}
	public int getNo() {
		return no;
	}
	public void setNo(int no) {
		this.no = no;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	@Override
	public String toString() 
	{
		return "no:" + no + " name:" + name + " score:" + score;
		
	}
	@Override
	public int hashCode() 
	{
		return Objects.hash(no);
	}
	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Student other = (Student) obj;
		return no == other.no;
	}
	
	
}

public class Main 
{
	public static void main(String[] args) 
	{
		Map<Integer,Student> map=new TreeMap<>();
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		for(int i=0;i<n;i++)
		{
			int id=scanner.nextInt();
			map.put(id, new Student(id, scanner.next(), scanner.nextInt()));
		}
		n=scanner.nextInt();
		for(int i=0;i<n;i++)
		{
			switch (scanner.next()) 
			{
				case "add": 
				{
					int id=scanner.nextInt();
					map.put(id, new Student(id, scanner.next(), scanner.nextInt()));
					break;
				}
				case "delete": 
				{
					map.remove(scanner.nextInt());
					break;
				}
				case "set":
				{
					int id=scanner.nextInt();
					Student student=map.get(id);
					student.setScore(scanner.nextInt());
					map.replace(id,student);
					break;
				}
				default:
					throw new IllegalArgumentException("Unexpected value");
			}
		}
		for (Integer student: map.keySet())
		{
			System.out.println(map.get(student));
		}
	}
}
